package com.pms.privilege.user.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.pms.privilege.user.dao.UserPrivDAO;
import com.pms.privilege.user.model.UserModel;
@Service(value="userservice01")
public class UserServiceImpl implements UserServiceBase{
	@Autowired
	private UserPrivDAO dao;
	@Override
	public List<UserModel> UserListService(int start, int end) {
		List<UserModel> list=new ArrayList<UserModel>();
		list=dao.queryUserList(start, end);
		if(list.size()>0){
			return list;
		}
		return null;
	}

	@Override
	public long TotalCountService() {
		return 0;
	}

	@Override
	public int insertUserService(UserModel um) {
		int result=-1;
		if(um!=null){
			result=dao.insertUserInfo(um);
		}
		return result;
	}

	@Override
	public int deleteUserService(long user_id) {
		int result=-1;
		dao.deletePermissionByUserID(user_id);
		dao.deleteFromDeptUser(user_id);
		result=dao.deleteUserInfo(user_id);
		return result;
	}

	@Override
	public int updateUserService(UserModel um) {
		int result=-1;
		result=dao.updateUserInfo(um);
		return result;
	}

	@Override
	public List<UserModel> userWithoutPermService(long func_id,int start,int end) {
		List<UserModel> list=new ArrayList<UserModel>();
		list=dao.queryUserListWithoutPerm(func_id, start, end);
		return list;
	}

}
